home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997 August / Macworld (1997-08).dmg / Shareware World / Info / For Developers / InstallerMaker™ 4.0 Installer / Customizing InstallerMaker / Installer Add-ons / Launch App / LaunchILst.c < prev    next >
C/C++ Source or Header  |  1997-05-07  |  6KB  |  140 lines

  1. /******************************************************************************
  2. **
  3. **  Project Name:    LaunchApp ILst
  4. **     File Name:    LaunchAppILst.c
  5. **
  6. **  File Description:     InstallerMaker 'ILst' extension that takes a path name
  7. **                        that ends in an application and launches that application 
  8. **                        Designed for CD installers who want to launch an application off the CD
  9. **                        without installing or referencing that application in the installer.
  10. **                        For Example the Quicktime 2.5 Installer.                 
  11. **
  12. **  Copyright© 1997 Aladdin Systems, inc.
  13. **
  14. *******************************************************************************
  15. **                       A U T H O R   I D E N T I T Y
  16. *******************************************************************************
  17. **
  18. **    KCQ            Kevin Quigley     Converted from E-Z ILoc to Plug Ins ILoc;
  19. **
  20. *******************************************************************************
  21. **                      L E G A L   N I C E T I E S
  22. *******************************************************************************
  23.  
  24.     This source code is (c) 1996 Aladdin Systems, Inc.  You are free to use it 
  25.     in connection with your own products and distribute it in either source code 
  26.     or object code form.  However, this source code and accompanying written 
  27.     materials (including instructions for use) are provided "as is" without 
  28.     warranty of any kind.  Further, Aladdin Systems does not warrant, or make 
  29.     representations regarding the use, or the results of the use, of the source 
  30.     code or written materials in terms of correctness, accuracy, reliability, 
  31.     currentness, or otherwise.  No oral or written information or advice given 
  32.     by Aladdin Systems or its employees shall create a warranty, and you may not 
  33.     rely on such information or advice.
  34.     
  35.     Neither Aladdin Systems nor anyone else who has been involved with the 
  36.     creation, production, or delivery of the source code shall be liable for 
  37.     any direct, indirect, consequential, or incidental damages (including damages 
  38.     for loss of business profits, business interruption, loss of business 
  39.     information, and the like) arising out of the use or the inability to use the 
  40.     source code even if Aladdin Systems has been advised of the possibility of 
  41.     such damages.  Because some states do not allow the exclusion or limitation 
  42.     of liability for consequential or incidental damages or the limitations of 
  43.     duration of implied warranty, the above limitations may not apply to you.
  44.  
  45. *******************************************************************************/
  46. typedef OSType **OSTypeHandle;
  47.  
  48.  
  49. pascal short main( unsigned long *refcon)
  50. {
  51.  
  52.     Str63                nameStr;
  53.     FSSpec                theFile;
  54.     OSErr                err;
  55.     LaunchParamBlockRec    theLaunch;
  56.     Handle                resource;
  57.     OSTypeHandle        crtr;
  58.     if (*refcon)
  59.         {
  60.         SetResLoad(false);
  61.         resource = GetResource('STR#',6051);
  62.         if (resource)
  63.             {
  64.             SetResLoad(true);
  65.             GetIndString(nameStr,6051,1);
  66.             err = FSMakeFSSpec(0,0,nameStr,&theFile);
  67.             if (!err)
  68.                 {
  69.                 theLaunch.launchBlockID = extendedBlock;
  70.                 theLaunch.launchEPBLength = extendedBlockLen;
  71.                 theLaunch.launchFileFlags = 0;
  72.                 theLaunch.launchControlFlags = launchNoFileFlags+launchContinue;
  73.                 theLaunch.launchAppSpec = &theFile;
  74.                 theLaunch.launchPreferredSize = 0L;
  75.                 theLaunch.launchMinimumSize = 0L;
  76.                 theLaunch.launchAvailableSize = 0L;
  77.                 theLaunch.launchAppParameters = 0L;
  78.                 LaunchApplication(&theLaunch);
  79.                 }
  80.             }
  81.         else
  82.             {
  83.             SetResLoad(true);
  84.             crtr = (OSTypeHandle) GetResource('CRTR',6051);
  85.             if (crtr)
  86.                 {
  87.                 DTPBRec            dtParam;                        // The DTPBRec we need to set up for the PBDT functions
  88.                 VolumeParam        theVolume;                        // VolumeParam for PB Get Info
  89.                 Str255            gFileName,vName;                // Buffers for the volume name and the name of the file to look for
  90.                 
  91.                 theVolume.ioVolIndex = 1;            // We want to index through the volumes so set the volume counter(index) to 1
  92.                 theVolume.ioCompletion = nil;        // We need no completion routine
  93.                 theVolume.ioNamePtr = vName;        // Point the namePtr to the vName Buffer (Probably not needed) set to nil
  94.                 
  95.                 err = PBGetVInfo((ParmBlkPtr)&theVolume,0);    // Get the first volume.
  96.                 while(!err)
  97.                     {
  98.                     dtParam.ioNamePtr = vName;                    // Set the volume to search name
  99.                     dtParam.ioVRefNum = theVolume.ioVRefNum;    // Set the volume to search volume ref number
  100.                     //*********************************
  101.                     PBDTGetPath(&dtParam);                        // Get the Desktop Path. (Absolutely essential)
  102.                     //*********************************
  103.                     
  104.                     // In order to save time the following three items could probably be placed before the while loop
  105.                     // but I don't know how PBDTGetPath alters the DTPBRec so I put them after the call to that trap
  106.                     
  107.                     dtParam.ioNamePtr = gFileName;                // Point the name buffer for the file name
  108.                     dtParam.ioIndex = 0;                        // Set the index to return the first item with the latest creation date
  109.                     dtParam.ioFileCreator = (long) (**crtr);        // Set the creator code of the file we want to find
  110.                     
  111.                     if (!PBDTGetAPPL(&dtParam,0))                // Search the Desktop DB and act on wether or not a file was found
  112.                         {
  113.                         err = FSMakeFSSpec(dtParam.ioVRefNum,dtParam.ioAPPLParID,gFileName,&theFile);
  114.                         if (!err)
  115.                             {
  116.                             theLaunch.launchBlockID = extendedBlock;
  117.                             theLaunch.launchEPBLength = extendedBlockLen;
  118.                             theLaunch.launchFileFlags = 0;
  119.                             theLaunch.launchControlFlags = launchNoFileFlags+launchContinue;
  120.                             theLaunch.launchAppSpec = &theFile;
  121.                             theLaunch.launchPreferredSize = 0L;
  122.                             theLaunch.launchMinimumSize = 0L;
  123.                             theLaunch.launchAvailableSize = 0L;
  124.                             theLaunch.launchAppParameters = 0L;
  125.                             LaunchApplication(&theLaunch);
  126.                             }
  127.                         return 0L;                                
  128.                         }
  129.                     theVolume.ioVolIndex++;                            // Incerment the volume index
  130.                     err = PBGetVInfo((ParmBlkPtr)&theVolume,0);    // and get the next volume    
  131.                     }                
  132.             
  133.                 
  134.                 }
  135.             }
  136.         }
  137.     return 0L;
  138.                             
  139. }
  140.